package com.merchant.util;

import com.google.common.collect.Sets;

import java.util.Random;
import java.util.Set;

/**
 * @program: merchant-register
 * @description: 手机号码生成类
 * @author: Vincent
 * @create: 2019-03-05 14:02
 **/
public class PhoneNumHelper {

    private static final String[] PHONE_PREFIX = new String[]{"13", "15", "18"};


    public static String genPhoneNum() {
        Random random = new Random();
        double num = random.nextDouble();

        String numStr = String.valueOf(num);

        Random prefixRandom = new Random();
        String phonePrefix = PHONE_PREFIX[prefixRandom.nextInt(10) % 3];

        return phonePrefix + numStr.substring(2, 11);
    }




    public static void main(String[] args) {
        Set<String> phones = Sets.newHashSet();
        for (int i=1; i<1000; i++) {
            String temp = genPhoneNum();
            phones.add(temp);
            System.out.println(temp);
        }
        System.out.println(phones.size());
    }

}
